import { observable, action } from 'mobx';
import { WeaTableNew, WeaForm } from 'comsMobx';
import * as API from '../apis/frame';

const { TableStore } = WeaTableNew;
import { WeaIntro } from 'ecCom';

const { Intro } = WeaIntro;

export class ComsStore {
  @observable title = '相册主页';
  @observable loading = false;
  @observable treeLoading = false;
  @observable conditionLoading = false;
  @observable rightMenuLoading = false;
  // table
  @observable dataKey = '';
  // tree
  @observable treeDatas = [];
  @observable treeTypes = [];
  // conditions
  @observable conditioninfo = [];
  // rightMenu
  @observable rightMenu = [];
  // form
  @observable form = new WeaForm();

  constructor() {
	this.setKey = this.setKey.bind(this);
    this.doLoading = this.doLoading.bind(this);
    this.doSearch = this.doSearch.bind(this);
    this.getConditionInfo = this.getConditionInfo.bind(this);
    this.getRightMenu = this.getRightMenu.bind(this);
  }

  @action
  doLoading(bool = false) {
    this.loading = bool;
    return this;
  }


  getRightMenu(module, params = {}) {
    this.rightMenuLoading = true;
    API.getRightMenu(module, params).then((data) => {
      this.rightMenu = data.rightMenus;
      this.rightMenuLoading = false;
    });
    return this;
  }

  getFormParams() {
    return this.form.getFormParams();
  }
}
